package com.gustuy.Reflect;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;

public class test3 {

    public static void main(String[] args) throws Exception {
        Class c=Class.forName("com.gustuy.Reflect.User");
        Method[] Met = c.getDeclaredMethods();
        Constructor[] declaredConstructors = c.getDeclaredConstructors();
        for (Method method : Met) {
            System.out.println(method);
        }
        for (Constructor declaredConstructor : declaredConstructors) {
            System.out.println(declaredConstructor);
        }
        User user = (User) c.newInstance();
        System.out.println(user);
        User xiaoming = (User) declaredConstructors[0].newInstance("Xiaoming", 5, 10);
        System.out.println(xiaoming);
       // Constructor declaredConstructors1 = c.getDeclaredConstructors(String.class, int.class, int.class);
        Met[1].invoke(user);
        Field name = c.getDeclaredField("name");
        name.setAccessible(true);
        name.set(user,"HHHH");
        System.out.println(user);

    }
}
